package study.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import study.entity.User;
import study.service.UserService;

import java.util.List;

/**
 * (User)表控制层
 *
 * @author makejava
 * @since 2020-09-15 13:48:44
 */
@RestController
@RequestMapping("user")
public class UserController {
    /**
     * 服务对象
     */
   @Autowired
    private UserService userService;

    @RequestMapping("findAll")
    public List<User> findall(){
        return userService.findAll();
    }
    @RequestMapping("add")
    public int add(){
        User user = new User();
//        user.setId(53);
        user.setName("haddh");
        int a=1;
        a=userService.add(user);
        System.out.println(user.getId());
        return a;
    }
    @GetMapping("selectOne")
    public User selectOne(Integer id) {
        return this.userService.queryById(id);
    }

}
